package com.jzr.pda.controller.api;

import com.jzr.common.entity.vo.Result;
import com.jzr.common.util.U;
import com.jzr.pda.db1.model.TCharge;
import com.jzr.pda.db1.service.TPatientService;
import com.jzr.pda.db1.vo.PatientVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "病人接口")
@RestController
@RequestMapping("/api/patient")
public class PatientController {
    @Autowired
    private TPatientService patientService;

    @ApiOperation("病人列表")
    @GetMapping("/list")
    public Result<List<PatientVo>> list(@ApiParam("科室编码") @RequestParam String deptCode){
        List<PatientVo> list = patientService.list(deptCode);
        return Result.success("成功",list,list.size());
    }

    @ApiOperation("病人花费")
    @GetMapping("/chargeInfo")
    public Result<TCharge> chargeInfo(@ApiParam("病人编码") @RequestParam String patientCode,
                                      @ApiParam("住院号") @RequestParam String patientCureNo){
        if(U.isBlank(patientCode)){
            return Result.fail("病人编码patientCode 不能为空");
        }
        if(U.isBlank(patientCureNo)){
            return Result.fail("住院号patientCureNo 不能为空");
        }
        TCharge charge = patientService.chargeInfo(patientCode,patientCureNo);
        return Result.success("成功",charge);
    }
}
